package LuoGu.贪心.线段覆盖;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [][] ans = new int[n][2];
        for(int i=0;i<n;i++){
            ans[i][0] = s.nextInt();
            ans[i][1] = s.nextInt();
        }
        Arrays.sort(ans, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1]-o2[1];
            }
        });
        int ansn = 1;
        int index = ans[0][1];
        for(int i=1;i<n;i++){
            if(index<=ans[i][0]){
                index = ans[i][1];
                ansn++;
            }
        }
        System.out.print(ansn);
    }
}
